package com.example.demo.spring.ioc.case01;

/**
 * 工厂类（根据,class文件实例化出对象）
 * @author: htc
 * @date: Created in 13:52 2019/1/10.
 */
public class Factory {
    public static Fruit getInstance(String className) {
        Fruit f = null;
        try {
            f = (Fruit) Class.forName(className).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return f;
    }
}
